package homework.day09;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @Classname: HomeWork02
 * @Author: bromide
 * @CreateTime: 2022/4/9--14:51
 * @Version: V1.0
 * @Description: 浏览器发送过来的请求内容每个字符单独读取出来并输出到控制台
 */
public class HomeWork02 {
    private ServerSocket serverSocket;

    public HomeWork02() {
        try {
            serverSocket = new ServerSocket(8077);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void start() {
        try {
            Socket socket = serverSocket.accept();
            InputStream in = socket.getInputStream();
            int i;
            while ((i = in.read()) != -1) {
                System.out.print((char) i);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        HomeWork02 ho = new HomeWork02();
        ho.start();
    }
}
